
#ifndef __TCP_CLIENT_H
#define __TCP_CLIENT_H

#include "netgeneral.h"
#include <vector>
#include <apr_file_io.h>
#include <apr_portable.h>
#include "../aprtools/APRBucketBrigade.h"

// Five seconds.
#define CLIENT_SOCKET_TIMEOUT 1000

class TCPClient
{
   public:
      TCPClient(const char *ihostname, int iportno, apr_pool_t *imp);
      ~TCPClient();
      int SendBuffer(const char *buf, int buflen);
      std::vector<char> *RecvBuffer(int len);
      int SendBucketBrigade(APRBucketBrigade *aprbb);
      std::vector<char> *SendAndRecvBuffer(const char *buf, int sendlen, int recvlen);
   protected:
      /** Is this a valid socket. */
      int isvalid;
      APRBucketBrigade *clientbb;
      apr_socket_t *tsocket;
      apr_sockaddr_t *addrstruct;
      apr_pool_t *mp;
};

#endif
